#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int N,A;
    int num = 0,i;
    int price[100],heat[100],ratio[100];

    while(cin>>N)
    {
        while(getchar() != '\n')
        {
            cin>>price[num];
            num++;
        }
        for (i=0; i<num;i++)
        {
            cin>>heat[i];
            ratio[i] = heat[i]/price[i];
        }
        
        sort(heat[0],heat[num])
        for(int i=0;i<N;i++)
        {
            if (step[i] >= step[i+1])
            {
                choice = step[i];
                score = score + step[i];
                i++;
            }
            else 
            {
                choice = step[i+1];
                score = score + step[i+1];
                i = i+2;
            }
        }
            cout<<score<<endl;
    }
    return 0;
}
